package io.renren.modules.store.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.store.entity.vo.StaffCommissionRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.store.dao.TStoreDiningTableDao;
import io.renren.modules.store.entity.TStoreDiningTableEntity;
import io.renren.modules.store.service.TStoreDiningTableService;


@Service("tStoreDiningTableService")
public class TStoreDiningTableServiceImpl extends ServiceImpl<TStoreDiningTableDao, TStoreDiningTableEntity> implements TStoreDiningTableService {

    @Autowired
    private TStoreDiningTableDao diningTableDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TStoreDiningTableEntity> page = this.page(
                new Query<TStoreDiningTableEntity>().getPage(params),
                new QueryWrapper<TStoreDiningTableEntity>()
                        .eq(!params.get("sellerId").equals(""),"seller_id",params.get("sellerId"))
                .eq(params.get("regionId")!= null , "region_id",params.get("regionId"))
                .eq(!params.get("key").equals(""),"dining_table_no",params.get("key"))
        );

        return new PageUtils(page);
    }

    @Override
    public List<Integer> getSeatNumList(Map<String,Object> map) {
        return diningTableDao.getSeatNumList(map);
    }

    @Override
    public void splitDesk(Map<String, Object> map) {
        diningTableDao.splitDesk(map);
    }


    @Override
    public TStoreDiningTableEntity getMaxNumberByPrefix(TStoreDiningTableEntity tableEntity) {
        return diningTableDao.getMaxNumberByPrefix(tableEntity);
    }

    @Override
    public Page<TStoreDiningTableEntity> queryTables(Map<String, Object> params) {
        Page<TStoreDiningTableEntity> page = new Page<TStoreDiningTableEntity>
                (Long.parseLong((String) params.get("page")),Long.parseLong((String) params.get("limit")));
        return diningTableDao.queryTables(page,params);
    }


}